<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title><style>
    .chuan{
        display:none;
        background-color:greenyellow;
        width: 200px;
        height: 50px;
        margin: auto;
        padding-top: 30px;

    }
    span{
      color: red;
        font-size: 12px;
    }


</style>
</head>
<link rel="stylesheet" href="/after/css/bootstrap.min.css">
<link rel="stylesheet" href="/after/css/laypage.css">
<script type="text/javascript" src="/after/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/after/js/laypage/laypage.js"></script>
<script type="text/javascript" src="/after/js/layer/layer.js"></script>
<script type="text/javascript" src="/after/js/vue/vue.min.js"></script>
<script src="/after/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script src="/after/jquery.validation/1.14.0/messages_zh.min.js"></script>
<script type="text/javascript" src="/before/js/jquery-3.1.1.min.js"></script>

<body style="text-align: center;margin-top: 50px;color: grey">

<span style="font-size: 25px;color:#FF9966;">修改密码</span><br><br>
<div class="form-group">
    <label for="pass">原密码：</label>
    <input type="password"  class="form-control" style="width: 350px;margin: auto;" name="password" id="password"/>
<span id="spassword"></span>
</div><div class="form-group">
<label for="pass">新密码：</label>
<input type="password" style="width: 350px;margin: auto;" class="form-control" name="pass" id="pass"/>
    <span id="spass"></span>
</div><div class="form-group">
<label for="pass">重复密码：</label>
<input type="password" style="width: 350px;margin: auto;" class="form-control" name="pass2" id="pass2"/><span id="error" style="color: red;font-size: 12px;"></span></div>
<button type="button" id="saveBtn" onclick="sub()" class="btn btn-success">确定</button>
</body>
<script>
    var getUser = function() {
        $.ajax({
            url : "/address/getUser.do",
            type : "POST",
            dataType : "json",
            success : function(msg) {
                console.log(msg)
                if(msg.hashMap.user==null){
                    top.location.href="HJHStageLogin.ftl";
                }
            }
        });
    }
    getUser();

</script>
</html>
<script>

function sub(){
    if($("#password").val()!=null && $("#password").val()!=""&&$("#pass").val()!=null && $("#pass").val()!=""&&$("#pass2").val()!=null && $("#pass2").val()!=""){

    if($("#pass").val()==$("#pass2").val()){
         console.log( $("#pass").val());
         $.ajax({
             url:"/address/updatepass.do",
             type:'post',
             dataType:'json',
             data:{
                 password:$("#password").val(),
                 pass:$("#pass").val()
             },  success : function(msg) {
                 console.log(msg)
                 if(msg.cheng==1){
                     layer.msg("修改成功")
                 }else if(msg.cheng==2){
                     layer.msg("密码错误")
                 }else{
                     layer.msg("修改失败")
                 }
             }



         })


     }else{
        $("#error").text("两次密码不一致");

    }
    }else{
        if($("#password").val()==null||$("#password").val()==""){
                $("#spassword").text("原密码不能为空")
        }
        if($("#pass").val()==null||$("#pass").val()==""){
            $("#spass").text("不能为空")
        }
        if($("#password").val()==null||$("#password").val()==""){
            $("#error").text("原密码不能为空")
        }
    }
}


</script>
